<?php
include('../Class/KhachHang_Class.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Xóa thông tin khách hàng </title>
<head>
</head>

<body>
<form action="Delete_KhachHang.php" method="post">
<div>Danh sách các khách hàng</div>
<div><a href="Add_KhachHang.php">Thêm Khách Hàng</a></div>
<div>
<?php
$khachhang=new KhachHang();
$sql=$khachhang->GetAll_KhachHang();
echo '<table  border="1">';
echo '<tr><td>MaKH</td><td>Tên Khách hàng</td><td>Địa chỉ</td><td>Số điện thoại</td><td>Email</td><td>Xóa / Sửa</td>';
echo '</tr>';
if (isset($_GET['p'])) $pindex = $_GET['p']; else $pindex = 1;
				$psize = 30;
				$khachhang=new KhachHang();
				$sql = $khachhang->get_by_page($psize,$pindex);
				$str_p = $khachhang->print_page();
while($row=@mysql_fetch_array($sql))
{
	echo "<tr>";
	echo "<td>".$row['MaKH']."</td>";
	echo "<td>".$row['TenKH']."</td>";
	echo "<td>".$row['DiaChi']."</td>";
	echo "<td>".$row['SoDT']."</td>";
	echo "<td>".$row['Email']."</td>";
	echo '<td><a href=Delete_KhachHang.php?id='.$row['MaKH'].'>Xóa</a> / <a href=Update_KhachHang.php?id='.$row['MaKH'].'>Sửa</a></td>';
	echo "</tr>";
}
echo '</table>';
echo "<div align='left'>Page ".$str_p."</div>";
?>


</div>
</form>
</body>
<?php
if(isset($_GET['id']))
{
	$id=$_GET['id'];
	if($khachhang->Delete_KhachHang($id)>0)
	{
		echo "Xóa thành công!!";
		header('location: Delete_KhachHang.php');
	}
	else
	{
		echo "Xóa thất bại!!".@mysql_error();
	}
}

?>
</html>
